#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char *str1 = argv[1];    // get the first string
    char *str2 = argv[2];    // get the second string
    int len1 = strlen(str1); // get the length of the first string
    int len2 = strlen(str2); // get the length of the second string

    // get the char which in str1 and most often in str2
    char most_match_char = 0;
    int most_match_count = 0;

    // loop the first string
    for (int i = 0; i < len1; i++)
    {
        char c = str1[i]; // get the char in str1
        int count = 0;    // count the char in str2

        // loop the second string
        for (int j = 0; j < len2; j++)
        {
            if (str2[j] == c)
            {
                count++;
            }
        }

        // if the count is bigger than the most_match_count
        // then update the most_match_char and most_match_count
        if (count > most_match_count)
        {
            most_match_char = c;
            most_match_count = count;
        }
    }

    // print the most_match_char
    printf("Most often: %c No. times: %d\n", most_match_char, most_match_count);

    return 0;
}
